﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace CardInChina.Data.Entity.Entity
{
    public partial class Card
    {
        public Card Load<T>()
        {
            using (CICEntities db = new CICEntities())
            {
                Card card = db.Cards.FirstOrDefault(c => c.CardID == this.CardID);

                PropertyInfo[] pis = typeof(Card).GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);
                foreach (var p in pis)
                {
                    if (p.PropertyType == typeof(T))
                        p.GetValue(card, null);
                }
                return card;
            }
        }

    }
}
